-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#567 add test suite #573
#567 add test suite #573
Conversation
@@ -1,12 +1,54 @@ | |||
tmp/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We weren't gitignoring log/test.log
, so instead of just adding this, I brought in the .gitignore
from a fresh rails app and refactored this a bit (our "custom" ones are at the bottom with some comments).
get comfy_cms_render_page_path(cms_path: 'hours-locations') | ||
|
||
assert_response :success | ||
assert_select "h1", /Hours & Locations/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The H1 tag on these pages has a lot of extra information in it, such as links and other things.
So for example for the "About us" page, you can see in this photo the links on the right is actually inside the <H1>
:
So using a regex to just extract and assert the actual header content here.
This could probably be improved by moving the extra info outside of the header tag.
@@ -0,0 +1,71 @@ | |||
name: CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly adapted from Jupiter's CI and Rails default generated CI https://github.com/rails/rails/blob/9ad3685538d9820dafadb70de9e2809486cdf91e/railties/lib/rails/generators/rails/app/templates/github/ci.yml.tt
branches: [ main ] | ||
|
||
jobs: | ||
# lint: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will like to add rubocop to the project later, so just stubbing this out for now
@@ -2,6 +2,14 @@ | |||
require_relative '../config/environment' | |||
require 'rails/test_help' | |||
|
|||
# Seed the database with our CMS seed data, if it's not already there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes here:
This will seed the test DB with our CMS data BEFORE the tests run, so it's technically outside the transactions that normally happen in the test suite. This is good because, every time we run tests, we don't need to reseed the DB (as this seeding is expensive, and takes a good ~30 seconds as we have many, many pages). It's bad in the case of what happens when the seed data changes? These changes won't be available right away, and will likely require someone to manually drop the test DB. But I assume changing the seed data is a rare occurrence.
I also tried to move this to a rake task but was having issues with Comfy
not being available.
Typically, we should be using fixtures here and following Comfy best practice here, which is to have a minimal version of our website for testing:
https://github.com/comfy/comfortable-mexican-sofa/wiki/HowTo:-Minimal-Fixtures-For-Testing
Or we can parse down the amount of CMS pages we have? As it appears, we have a ton of redundant/old pages or multiple versions (sandbox/french) of our CMS.
The less we have, the faster the seeding can take place, which means we could in theory just use fixtures and seed the CMS every time before the tests run, which means we could get the best of both worlds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
# Our custom ignores | ||
.DS_Store | ||
# This is ignored due to Ansible I assume: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume too.
|
||
require "test_helper" | ||
|
||
class CmsTest < ActionDispatch::IntegrationTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done later, but it would be good to cover the features noted in the readme:
- home page
- staff (view, new and edit)
- admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that sounds like a good idea, especially Staff as this is custom (not part of the CMS) 👍. So will add a note to add more tests for this here #567
Attempt at adding a few smoke tests just to verify the CMS is running correctly.
This will hopefully add a pattern we can build off in the future.
This also adds a very simple CI runner that will run these tests.